package edu.neu.swc.commerce.converter;

import edu.neu.swc.commerce.constant.BrandCategory;

import javax.persistence.AttributeConverter;

/**
 * <h1>品牌分类枚举属性转换器</h1>
 */
public class BrandCategoryConverter implements AttributeConverter<BrandCategory,String> {

    /**
     * <h2></h2>
     */
    @Override
    public String convertToDatabaseColumn(BrandCategory brandCategory) {
        return brandCategory.getCode();
    }

    /**
     * <h2></h2>
     */
    @Override
    public BrandCategory convertToEntityAttribute(String s) {
        return BrandCategory.of(s);
    }
}
